package main

import (
	"ginblog/dao"
	"ginblog/model"
	"ginblog/routers"
)

func main() {

	//链接数据库
	err := dao.InitMySQL()
	if err != nil {
		panic(err)
	}
	defer dao.Close()

	err = dao.SetupRedisDb()
	if err != nil {
		panic(err)
	}

	//绑定模型
	dao.DB.AutoMigrate(&model.Article{})
	dao.DB.AutoMigrate(&model.User{})

	//开启gin
	r := routers.SetupRouter()
	r.Run()
}
